package com.ssy.lingxi.order.controller.web;

import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.order.model.vo.basic.request.OrderPayChannelVO;
import com.ssy.lingxi.order.model.vo.payment.request.PaymentParameterInsertOrUpdateVO;
import com.ssy.lingxi.order.model.vo.payment.response.PaymentParameterItemVO;
import com.ssy.lingxi.order.model.vo.payment.response.PaymentParameterPayTypeDetailVO;
import com.ssy.lingxi.order.service.web.IMemberPaymentParameterService;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu 支付能力 - 会员支付参数配置
 * @author 万宁
 * @version 2.0.0
 * @date 2021-08-12
 */
@RestController
@RequestMapping("/order/member/payment/parameter")
public class MemberPaymentParameterController {
    @Resource
    private IMemberPaymentParameterService memberPaymentParameterService;

    /**
     * 查询支付参数配置详情
     * @param headers HttpHeaders信息
     * @return 查询结果
     */
    @RequestMapping(value = "/find", method = RequestMethod.GET)
    public Wrapper<List<PaymentParameterPayTypeDetailVO>> findMemberPaymentParameters(@RequestHeader HttpHeaders headers) {
        return memberPaymentParameterService.findMemberPaymentParameters(headers);
    }

    /**
     * 根据支付渠道，查询支付参数下拉框列表
     * @param headers HttpHeaders信息
     * @param channelVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/channel/find", method = RequestMethod.GET)
    public Wrapper<List<PaymentParameterItemVO>> findMemberPaymentPayChannelParameters(@RequestHeader HttpHeaders headers, @Valid OrderPayChannelVO channelVO) {
        return memberPaymentParameterService.findMemberPaymentPayChannelParameters(headers, channelVO);
    }

    /**
     * 新增或修改会员支付参数设置
     * @param headers HttpHeaders信息
     * @param parameterVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/create", method = RequestMethod.POST)
    public Wrapper<Void> createMemberPaymentParameters(@RequestHeader HttpHeaders headers, @RequestBody @Valid PaymentParameterInsertOrUpdateVO parameterVO) {
        return memberPaymentParameterService.createMemberPaymentParameters(headers, parameterVO);
    }
}
